package com.bss.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.andy.basics.AbstractEntity;

@Entity
@Table(name = "materialallocation")
public class MaterialAllocation extends AbstractEntity {

	private static final long serialVersionUID = 4982847623886165170L;
	private int id;
	private MaterialType materialType = new MaterialType();
	private Admission admission = new Admission();
	private Date dateAllocated = new Date();
	private Date dateReturned = new Date();
	private int instances;

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final int id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idMaterialType")
	public MaterialType getMaterialType() {
		return this.materialType;
	}

	public void setMaterialType(final MaterialType materialType) {
		this.materialType = materialType;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idAdmission")
	public Admission getAdmission() {
		return this.admission;
	}

	public void setAdmission(final Admission admission) {
		this.admission = admission;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "dateAllocated", length = 19)
	public Date getDateAllocated() {
		return this.dateAllocated;
	}

	public void setDateAllocated(final Date dateAllocated) {
		this.dateAllocated = dateAllocated;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "dateReturned", length = 19)
	public Date getDateReturned() {
		return this.dateReturned;
	}

	public void setDateReturned(final Date dateReturned) {
		this.dateReturned = dateReturned;
	}

	public void setInstances(final int instances) {
		this.instances = instances;
	}

	@Column(name = "instances")
	public int getInstances() {
		return this.instances;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", length = 19)
	public Date getDate() {
		return this.date;
	}

}
